#include <iostream>
using namespace std;

int main()
{
    //实现数组元素的逆置

    //1、创建数组
    int arr[5] = {1,3,2,5,4};
    cout << "数组逆置前：" << endl;
    for(int i=0;i<5;i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;

    //2、实现逆置 ———— 前后元素互换
    int start = 0;
    int end = sizeof(arr) / sizeof(arr[0]) - 1;
    for(;start < end;start++,end--){
        //互换
        int temp = arr[start];
        arr[start] = arr[end];
        arr[end] = temp;
    }
    
    //3、打印逆置后的数组
    cout << "数组逆置后：" << endl;
    for(int i=0;i<5;i++)
    {
        cout << arr[i] << " ";
    }
    cout << endl;

    return 0;
}